home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vbrowser
/
vbrowser.frm
< prev
next >
Wrap
Text File
|
1995-10-20
|
7KB
|
216 lines
VERSION 2.00
Begin Form browserfrm
AutoRedraw = -1 'True
Caption = "VBrowser"
ClientHeight = 5835
ClientLeft = 1140
ClientTop = 2130
ClientWidth = 7365
Height = 6240
Left = 1080
LinkTopic = "Form1"
ScaleHeight = 5835
ScaleWidth = 7365
Top = 1785
Width = 7485
Begin TextBox Text1
Height = 3735
Left = 0
MousePointer = 1 'Arrow
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 3
Top = 2040
Width = 7335
End
Begin MsgBlaster MsgBlaster1
Prop8 = "Click on ""..."" for the About Box ---->"
Prop9 = "Click on ""..."" for the Message Center --->"
Left = 6000
MsgList = VBROWSER.FRX:0000
MsgPassage = VBROWSER.FRX:0064
TargetName = "browserfrm"
Top = 600
UserMsgs = VBROWSER.FRX:0096
Version = "2.1a"
End
Begin CommandButton connbtn
Caption = "&Connect"
Height = 495
Left = 3000
TabIndex = 2
Top = 600
Width = 1695
End
Begin TextBox conntxt
Height = 285
Left = 1200
TabIndex = 0
Text = "http://"
Top = 240
Width = 5775
End
Begin Label url
Height = 255
Left = 120
TabIndex = 5
Top = 1680
Width = 7095
End
Begin Label Sockstatus
Height = 255
Left = 120
TabIndex = 4
Top = 1200
Width = 7215
End
Begin Label Label1
Caption = "Connect:"
Height = 255
Left = 240
TabIndex = 1
Top = 240
Width = 855
End
End
Sub connbtn_click ()
'Ask for index.htm
document$ = "/"
call_server (Trim$(conntxt.Text))
End Sub
Sub conntxt_KeyPress (keyascii As Integer)
If keyascii = 13 Then
connbtn_click
End If
End Sub
Sub Form_Load ()
status% = start_winsock()
End Sub
Sub Form_Unload (cancel As Integer)
cancel = True
quit_flag = True
End Sub
Sub MsgBlaster1_Message (msgval As Integer, wparam As Integer, lparam As Long, ReturnVal As Long)
nodef = True 'No further message processing(for message blaster)
'wParam is handle, lParam=event
'SEE Winsock.txt
'NOTE NOTE NOTE NOTE
'Msgblast has a weirdness. To set the messages you want
'to trap, and the win handle, use the properties window
'for Msgblast. Click on 'message center'. If you LOOK at
'the message settings you may lose them. So if you lose
'the settings they are:
'Trap messages for 'browserfrm'
'Add user message 'EVENTMSG' (any name actually will do)
'number 8192.
'Add user message 'NAMEMSG' number 8193.
'Click the 'msg will be eaten' for both.
'wparam=namehandle when we made call
'lparam=any error code(hi word), event type (loword)
'Set globals so anybody can use
event_type% = lparam And &HFFFF&
event_error% = (lparam \ &H10000) And &HFFFF&
event_wparam% = wparam
If msgval = event_msg% Then
'Either got a close or a receive
If event_type% = FD_READ Then
'Received something, so read it
rxbuff$ = Space$(4096)
rxbufflen = Len(rxbuff$)
status% = recv(callsocket%, rxbuff$, rxbufflen, 0)
If status% = SOCKET_ERROR Then
status% = WSAGetLastError()
dprint "Read ERROR " + sockerror$(status%)
Else
rmsg$ = Left$(rxbuff$, status%)
If Len(current_msg$) = 0 Then
'Start of msg
current_msg$ = rmsg$
Else
'next segment
current_msg$ = current_msg$ + rmsg$
End If
dprint "Read " & Len(rmsg$) & " bytes."
End If
ElseIf event_type% = FD_CLOSE Then
'Got a close
'NOTE: Web servers will send the requested message and then
'disconnect. In theory, the received data should be received
'here BEFORE the connect is seen. i.e., our Winsock should receive
'all the data, send a receive message, and Then send the
'close message. Not so. Notice that sometimes you will get the
'close event message while their is still data to receive.
'By using a global closed status flag it appears that the data receive
'windows message will interrupt the main routine as soon as we exit
'the Msgblast routine, which throws us immediately back into the Msgblast
'receive data routine which the gets the data. It looks like the main
'recieve loop never gets a chance to recognize the closed flag. This is
'a bit too close for comfort and one should probably use the Winsock status
'call(s) to see if there is more data to be received before issuing a close
'socket. However, I have not missed any data yet. Wouldn't it be nice if
'Winsock specifications clearly explained what is happening?
dprint "Close received for socket " & wparam
'Set global flag
closed = True
End If
ElseIf msgval = name_msg% Then
dprint "Name response received. lparam: " & Hex$(lparam) & "x " & lparam
got_name_response = True
End If
End Sub
Sub Text1_Click ()
ipt = text1.SelStart
For i = ipt To 1 Step -1
c$ = Mid$(text1.Text, i, 1)
If c$ = "[" Then
flag = True
Exit For
ElseIf c$ = "]" Then
Exit For
End If
l$ = c$ + l$
Next
If flag Then
flag = False
For i = ipt + 1 To Len(text1.Text)
c$ = Mid$(text1.Text, i, 1)
If c$ = "]" Then
flag = True
Exit For
ElseIf c$ = "[" Then
Exit For
End If
l$ = l$ + c$
Next
End If
If flag Then
document$ = ""
delim = InStr(links$, l$)
If delim Then
For i = delim - 2 To 1 Step -1
c$ = Mid$(links$, i, 1)
If c$ = "]" Then
Exit For
Else
document$ = c$ + document$
End If
Next
If Len(document$) Then
call_server (Trim$(conntxt.Text))
End If
End If
End If
End Sub